<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title></title>
	<meta id="viewport" name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0" />
	<meta name="format-detection" content="telephone=no" />
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
	<link rel="stylesheet" type="text/css" href="css/aui.css"/>
</head>
<body style="background-color: #fff">

<div class="scrollload-containernew">
	<div id="content" class="scrollload-contentnew" style="padding-bottom: 40px;overflow: hidden;">

	</div>
</div>
</body>

<style type="text/css">
	.toFlip{display:none;}
	.txt img{
		width: 100%;
	}
</style>
<script id="theme_tem" type="text/html">
	{{each themeArr}}
	<div onclick="goTOThemeDetail({{$value.themeid}})" class="col-xs-12" style="min-height: 9.5rem;height:auto;width:100%;padding:1rem;">
		<div class="col-xs-4" style="height:9.17rem;width: 29.3333%;padding:0rem;>
		        <a href="javascript:;" style="display:block;height: 100%;">
		<img src="{{$value.img | addUrl}}" style="box-shadow:0.1rem 0.1rem 1rem #e6e6e6;width: 9.17rem;height: 9.17rem;margin: 0;border: 0;vertical-align: middle;border-radius: 3%/5%;">
		</a>
	</div>
	<div class="col-xs-8" style="position: relative;height:9.17rem;width:68.666666%;top:0rem;left:1rem;padding: 0.2rem 0.6rem 0.5rem 0rem;">
		<span class="aui-ellipsis-2 " style="position: relative;left:0rem;margin: 0;font-size: 1.5rem;line-height:1.7rem;font-weight: bold;overflow: hidden;white-space: nowrap;text-overflow:ellipsis ;">{{$value.title}}</span>
		<p class="aui-ellipsis-2" style="position: relative;top:0.5rem;line-height:1.5rem;font-size:1.3rem;color: #666;margin-top: 0.33rem;height: 2.8rem;margin-bottom: 0;">{{$value.contentabstract}}</p>
		<div style="position:absolute;bottom: 0;">
			<span style="float:left;color: #666;font-size: 1.3rem;line-height: 1.3rem;margin-top: .5rem;border-right:1px solid #999999;padding-right: .46rem;">{{$value.book_count}}本书</span>
			<span style="float:left;color: #666;font-size: 1.3rem;line-height: 1.3rem;margin-top: .5rem;padding-left: .46rem;">{{$value.clickCount | totalReadCount}}人在听</span>
		</div>
	</div>
	</div>
	{{/each}}
</script>

<script id="small_tem" type="text/html">
	{{each themeArr}}
	<div onclick="goTOThemeDetail({{$value.bookid}})" class="col-xs-12" style="min-height: 9.5rem;height:auto;width:100%;padding:1rem;">
		<div class="col-xs-4" style="height:9.17rem;width: 29.3333%;padding:0rem;>

		    	<a href="javascript:;" style="display:block;height: 100%;">
		<img src="{{$value.bookimg | addUrl}}"/ style="box-shadow:0.1rem 0.1rem 1rem #e6e6e6;width: 9.17rem;height: 9.17rem;margin: 0;border: 0;vertical-align: middle;border-radius: 3%/5%;">
		</a>
	</div>
	<div class="col-xs-8" style="position: relative;height:9.17rem;width:68.666666%;top:0rem;left:1rem;padding: 0.2rem 0.6rem 0.5rem 0rem;">
		<span class="aui-ellipsis-2 " style="position: relative;left:0rem;margin: 0;font-size: 1.5rem;line-height:1.7rem;font-weight: bold;overflow: hidden;white-space: nowrap;text-overflow:ellipsis ;">{{$value.bookname}}</span>
		<p class="aui-ellipsis-2" style="position: relative;top:0.5rem;line-height:1.5rem;font-size:1.3rem;color: #666;margin-top: 0.33rem;height: 2.8rem;margin-bottom: 0;">{{$value.bookrecommend}}</p>
		<div style="position:absolute;bottom: 0;">
			{{if $value.isorder == 1 || userVip.type == 1}}
			<p style="float:left;color: #feb255;font-size: 1.3rem;line-height: 1.3rem;margin-top: .5rem;">已购买</p>
			{{else}}
			<p style="float:left;color: #999;font-size: 1.3rem;line-height: 1.3rem;margin-top: .5rem;">{{$value.bookprice}}元/共{{$value.chaptercount}}节</p>
			{{/if}}
		</div>
	</div>
	</div>
	{{/each}}
</script>

<script src="js/out7.js" type="text/javascript" charset="utf-8"></script>
<script src="js/aui-toast.js" type="text/javascript" charset="utf-8"></script>
<script src="js/zepto.js" type="text/javascript" charset="utf-8"></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="js/md5.js" type="text/javascript" charset="utf-8"></script>
<script src="js/art-template.js" type="text/javascript" charset="utf-8"></script>
<script src="js/wxrem.js" type="text/javascript" charset="utf-8"></script>
<!--<script src="//s.url.cn/qqun/qun/qqweb/m/qun/confession/js/vconsole.min.js"></script>-->
<script type="text/javascript">
    document.writeln("<script type=\"text/javascript\" src=\"js/common.js?"+ Math.random() + "\"></scr"+"ipt>");
</script>
<script type="text/javascript">
    var toast = new auiToast();
    var page = 1
    var themeArr = new Array();
    var type = GetQueryString('type');
    //设置导入模板变变量
    var imgHosturl = "http://img.readerday.com/cover/";
    template.defaults.imports.addUrl = function(value){
        if(value==""){
            return "img/book.png"
        }else{
            return imgHosturl+value
        }
    };

    template.defaults.imports.totalReadCount = function(value){
        value = value.toString();
        if(value.length<=4){
            return value;
        }else{
            value = value/10000;
            return value = value.toFixed(1)+"万"
        }
    };

    function goTOThemeDetail(id){
        if (type == 1) {
            window.location.href = "smallCourseDetail.html?bookid=" + id;
        }else {
            window.location.href = "listDetail.html?themeId="+id;
        }
    }

    var refreshUpOrDown = function(){
        var themeList_refresh = new Scrollload({
            container: document.querySelector('.scrollload-containernew'),
            content: document.querySelector('.scrollload-contentnew'),
            noMoreDataHtml : '<div id="slogen" align="center" class="col-xs-12" style="padding-bottom: 3.75rem;padding-top:2rem;height: 1.17rem; width:92%;font-size:1.4rem;left:4%">'+
            slogenFont[rand(0,slogenFont.length)]+
            '</div>',
            loadMore:function(sl){//上拉加载

                if (page >= 2) {
                    getThemeListUp(sl);
                }
            },
            enablePullRefresh: true,
            pullRefresh:function(refreshDown){//下拉刷新
                getThemeListDown(refreshDown);
                refreshDown.refreshComplete()
            }
        });
    }

    var getThemeListUp = function(sl){//上拉加载
        var sign = hex_md5(objKeySort({token:token,timestamp:date,type:1,page:page,rows:'10',merchantId:merchantId}))
        var url= hostUrl + 'product/theme/list/'+ token +'/'+ sign +'/'+ date + '/' + merchantId + '/1/'+ page +'/10';
        if(type==1){
            sign = hex_md5(objKeySort({token:token,timestamp:date,type:1,page:page,rows:'10',merchantId:merchantId}))
            url = hostUrl + 'product/book/list/'+ token +'/'+ sign +'/'+ date + '/' + merchantId + '/1/1/'+ page +'/10'

        }
        $.ajax({
            type:"get",
            url:hostUrl + 'product/book/list/'+ token +'/'+ sign +'/'+ date + '/' + merchantId +'/1/1/'+ page +'/10',
            async:true,
            success:function(data){
                if (type == 1) {
                    if (data.status != 0 || !data.data.book_list.length) {
                        if (sl) {
                            sl.noMoreData()
                        }
                        return;
                    }
                } else{
                    if (data.status != 0 || !data.data.list.length) {
                        if (sl) {
                            sl.noMoreData()
                        }
                        return;
                    }
                }
                page ++;
                data.userVip=userVip;

                if (type == 1) {
                    for (var i = 0; i < data.data.book_list.length; i ++) {
                        var dict = data.data.book_list[i];
                        themeArr.push(dict);
                    }
                } else{
                    for (var i = 0; i < data.data.list.length; i ++) {
                        var dict = data.data.list[i];
                        themeArr.push(dict);
                    }
                }
                data.themeArr = themeArr;
                if (type == 1) {
                    var theme_html = template("small_tem",data);
                    document.getElementById('content').innerHTML = theme_html;
                }else {
                    var theme_html = template("theme_tem",data);
                    document.getElementById('content').innerHTML = theme_html;
                }
                if (sl) {
                    sl.unLock()
                }
            }
        });
    }

    var getThemeListDown = function(refreshDown){//下拉刷新
        toast.loading({
            title: "加载中",
            duration: 2000
        });
        var sign = hex_md5(objKeySort({token:token,timestamp:date,type:1,page:page,rows:'10',merchantId:merchantId}))
        var url= hostUrl + 'product/theme/list/'+ token +'/'+ sign +'/'+ date+ '/' + merchantId +'/1/'+ page +'/10';
		if(type==1){
             sign = hex_md5(objKeySort({token:token,timestamp:date,type:1,page:page,rows:'10',merchantId:merchantId}))
             url = hostUrl + 'product/book/list/'+ token +'/'+ sign +'/'+ date+ '/' + merchantId +'/1/1/'+ page +'/10'
		}
        $.ajax({
            type:"get",
            url:url,
            async:true,
            success:function(data){
                toast.hide();
                if (data.status != 0) {
                    return;
                }
                page = 2;
                data.userVip=userVip
                if (type == 1) {
                    themeArr = data.data.book_list;
                } else{
                    themeArr = data.data.list;
                }
                data.themeArr = themeArr;
                if (type == 1) {
                    var theme_html = template("small_tem",data);
                    document.getElementById('content').innerHTML = theme_html;
                }else {
                    var theme_html = template("theme_tem",data);
                    document.getElementById('content').innerHTML = theme_html;
                }
                if (refreshDown) {
                    refreshDown.refreshData();
                    refreshDown.unLock()
                }else{
                    refreshUpOrDown();
                }
            }
        });
    }
    getToken(getThemeListDown);

</script>
</html>
